package dao.impl;

import dao.BookTypeDao;
import pojo.BookType;

import java.sql.SQLException;
import java.util.ArrayList;

public class BookTypeDaoImpl extends BaseDao implements BookTypeDao {
    @Override
    public ArrayList<BookType> getBookTypeList() {
        String strSQl= "Select * from  booktype";
        ArrayList<BookType> bookTypeList = new ArrayList<BookType>();
        BookType bookType =null;

        // 建立连接
        this.conn = this.getConnection();
        try {
            this.state =this.conn.createStatement();
            this.rs = this.state.executeQuery(strSQl);

            while(rs.next()){
                bookType = new BookType();
                bookType.settID(rs.getInt(1));
                bookType.settName(rs.getString(2));
                bookTypeList.add(bookType);
            }

        } catch (SQLException e) {
            e.printStackTrace();
        }

        return bookTypeList;
    }
}
